import 'package:floor/floor.dart';
import 'package:number_spark_flutter/db_manager/dao/ns_record_dao.dart';
import '../db_manager/db/app_database.dart';

class NSDBUtils {
  //单例
  factory NSDBUtils() => _getInstance();

  static NSDBUtils get instance => _getInstance();
  static NSDBUtils? _instance;
  static String? databasesPath;

  NSDBUtils._internal() {}

  static NSDBUtils _getInstance() {
    _instance ??= NSDBUtils._internal();
    return _instance!;
  }

  //定义数据库变量
  late final AppDatabase _db;

  NSRecordDao get daoRecord => _db.recordDao;

  initDB() async {
    _db = await $FloorAppDatabase.databaseBuilder('app_database.db_manager').addMigrations(
      [],
    ).build();
  }
}
